.<!DOCTYPE html>
<html>
	<head>
		<title>电话回访登记查询</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">
		<%include("/common/include.html"){}%>
	</head>
	<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<style type="text/css">
		.textbox{
			padding-right:0px;
			background:url("${cxt !}/sb/themes/insdep/images/combo_arrow.png") no-repeat scroll right center transparent;
		} 
	</style>
	<script type="text/javascript">
		$(function() {
			var $form_div = $("#queryByCustom div");
			winResize($form_div);
			$(window).resize(function(){//当调整浏览器窗口的大小时，发生 resize 事件
				winResize($form_div);
			});
		})
		function btn1(ids){
			
			loadDialog($('#datagrid'),null, '回访', 'scallVisit/showscallVisit?customerIds='+ids);
		};
		
		function btn2(ids){
			loadDialog($('#datagrid'),null, '查询', 'scallVisit/queryByCallVisit?ids='+ids);
		};
		
		$(document).ready(function () {		
			queryCustomer();
		})
		function queryCustomer(){
			$('#datagrid').datagrid({
				queryParams: {
					'_query.organIdsEmployee': $("#organIdsEmployee").val(),
					'_query.name': $("#name").val(),
					'_query.phone': $("#phone").val(),
					'_query.arrivedMinDate': $("#arrivedMinDate").val(),
					'_query.arrivedMaxDate': $("#arrivedMaxDate").val(),
					'_query.minResultLostWeight': $("#minResultLostWeight").val(),
					'_query.maxResultLostWeight': $("#maxResultLostWeight").val(),
					'_query.arrivedMinTimes': $("#arrivedMinTimes-temp").val(),
					'_query.arrivedMaxTimes': $("#arrivedMaxTimes-temp").val(),
					'_query.minLostWeightAmount': $("#minLostWeightAmount").val(),
					'_query.maxLostWeightAmount': $("#maxLostWeightAmount").val(),
					'_query.isSatisfaction': $("#isSatisfaction").val(),
				},
				singleSelect: true,
				rownumbers: true, //显示序号
				pagination: true,
				pageSize: 10,
				url:'scallVisit/queryByCustom',
				collapsible: true,
				columns:[[
			  		{field:'name',title:'名称',width:100,align:'center'},
			  		//{field:'phone',title:'手机',width:100,align:'center'},
			  		{field:'jdrq',title:'首次进店日期',width:100,align:'center'},
			  		{field:'tostoredate',title:'最近到店日期',width:100,align:'center'},
			  		{field:'firstweight',title:'最初体重',width:64,align:'center',
						formatter: function(value,row,index){
							if(row.firstweight != null){
								var a=row.firstweight+'斤';
								return  a;
							}
						}},
			  		{field:'delweight',title:'应减体重',width:64,align:'center',
						formatter: function(value,row,index){
							if(row.delweight != null){
								var a=row.delweight+'斤';
								return  a;
							}
						}},
			  		{field:'nowweight',title:'最后体重',width:64,align:'center',
						formatter: function(value,row,index){
							if(row.nowweight != null){
								var a=row.nowweight+'斤';
								return  a;
							}
						}},
			  		{field:'coun',title:'到店次数',width:50,align:'center',
						formatter: function(value,row,index){
							if(row.coun!= null){
								var a=row.coun+'次';
								return  a;
							}
						}},
			  		{field:'reducedWeight',title:'已减斤数',width:100,align:'center',
						formatter: function(value,row,index){
							if(row.firstweight != null && row.nowweight != null){
								var a=row.firstweight-row.nowweight;
								a= a.toFixed(1);
								return  a+'斤';
							}
						}},
			  		{field:'resultWeight',title:'减重效果',width:100,align:'center',
						formatter:function(value,row,index){
							if(row.firstweight != null && row.nowweight != null){
								var b=row.firstweight-row.nowweight;
								var bb=(b/row.delweight)*100;
								bb = bb.toFixed(1);
								return bb+'%';
							}
						}},
			  		{field:'lastcallvisittime',title:'上次回访时间',width:100,align:'center'},
			  		{field:'issatisfaction',title:'满意度',width:50,align:'center',
						formatter:function(value,row,index){
							if(value == 1){
								return '满意';
							}else if(value==2){
								return '一般';
							}else if(value==3){
								return '差';
							}
						}},
			  		{field:'YNContent',title:'操作',width:100,align:'center',
						formatter:function(value,row,index){
							return '<a onclick='+'btn1(\'' + row.idscutomer + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:red'+' class='+'l-btn-text'+'>回访</span></span></a>'
							+'<a onclick='+'btn2(\'' + row.idscutomer + '\')'+' class='+'button-edit button-success  l-btn l-btn-small'+'><span class='+'l-btn-left'+'><span  style='+'color:green'+' class='+'l-btn-text'+'>查询</span></span></a>';
					}},
					]]
			});		
		};
		function queryCustomerExcel(){
			var organIdsEmployee = $("#organIdsEmployee").val();
			var name = $("#name").val();
			var phone = $("#phone").val();
			var arrivedMinDate = $("#arrivedMinDate").val();
			var arrivedMaxDate = $("#arrivedMaxDate").val();
			var minResultLostWeight = $("#minResultLostWeight").val();
			var maxResultLostWeight = $("#maxResultLostWeight").val();
			var arrivedMinTimes = $("#arrivedMinTimes-temp").val();
			var arrivedMaxTimes = $("#arrivedMaxTimes-temp").val();
			var minLostWeightAmount = $("#minLostWeightAmount").val();
			var maxLostWeightAmount = $("#maxLostWeightAmount").val();
			var isSatisfaction = $("#isSatisfaction").val();
			var url = 
			"${cxt!}/scallVisit/excel?name="
			+name+
			"&phone="
			+phone+
			"&arrivedMinDate="
			+arrivedMinDate+
			"&arrivedMaxDate="
			+arrivedMaxDate+
			"&minResultLostWeight="
			+minResultLostWeight+
			"&maxResultLostWeight="
			+maxResultLostWeight+
			"&arrivedMinTimes="
			+arrivedMinTimes+
			"&arrivedMaxTimes="
			+arrivedMaxTimes+
			"&minLostWeightAmount="
			+minLostWeightAmount+
			"&maxLostWeightAmount="
			+maxLostWeightAmount+
			"&isSatisfaction="
			+isSatisfaction+
			"&organIdsEmployee="
			+organIdsEmployee;
			window.location.href = url;
		}
</script>
	<body class="easyui-layout">
		<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">				
			<form id="queryByCustom"  method="post">
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">店面名称：</label>
					<input id="organEmployee" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenuEmployee(); return false;" class="textbox" value="${curOrgan.name! }"/>
					<input name="selOrganIds" id="organIdsEmployee" type="hidden" value="${curOrgan.ids! }">
				</div>
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">姓名：</label>
					<input name="_query.name" id="name" style="height:32px;width:212px;text-align:center" class="easyui-textbox theme-textbox-radius" />
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">手机号：</label>
					<input name="_query.phone" id="phone" style="height:32px;width:212px;text-align:center" class="easyui-textbox theme-textbox-radius" />
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最早到店日期：</label>
					<input name="_query.arrivedMinDate" id="arrivedMinDate" class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center"
						data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最晚到店日期：</label>
					<input name="_query.arrivedMaxDate" id="arrivedMaxDate" class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center"
						data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最小减重效果：</label>
					<input name="_query.minResultLostWeight" id="minResultLostWeight" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最大减重效果：</label>
					<input name="_query.maxResultLostWeight" id="maxResultLostWeight" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最少到店次数：</label>
					<input name="_query.arrivedMinTimes" id="arrivedMinTimes-temp" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最多到店次数：</label>
					<input name="_query.arrivedMaxTimes" id="arrivedMaxTimes-temp" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最小减重斤数：</label>
					<input name="_query.minLostWeightAmount" id="minLostWeightAmount" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">最大减重斤数：</label>
					<input name="_query.maxLostWeightAmount" id="maxLostWeightAmount" class="easyui-textbox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">满意度：</label>
					<select name="_query.isSatisfaction" id="isSatisfaction" class="easyui-combobox theme-textbox-radius" style="height:32px;width:212px;text-align:center">
						<option value="">全部</option>
						<option value="1">满意</option>
						<option value="2">一般</option>
						<option value="3">差</option>
					</select>
				</div>
				
				<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
					<label class="label-top" style="width: 100%; display: block;">搜索</label>
					<a href="#" onclick="queryCustomer()" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="height:32px;width:212px;text-align:center">搜索</a>
				</div>
				<div style="margin-bottom: 10px;float:left;">
					<label class="label-top" style="width: 100%; display: block;">导出</label>
					<a href="#" onclick="queryCustomerExcel()" class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:212px">导出</a>
				</div>
			</form>
		</div>
		<div data-options="region:'center'" style="overflow-x:hidden;">
			<table id="datagrid" style="width: 100%; height: 100%;"></table> 
		</div>
		<div id="menuContentEmployee" class="menuContentEmployee" style="display: none; position: absolute;z-index: 10;">
			<ul id="organSelectTreeEmployee" class="ztree" style="margin-top: 0;width: 200px;"></ul>
		</div>
		<!-- 店员标签门店树形图 -->
		<script type="text/javascript">
			var organIdsEmployee=$('#organIdsEmployee').val();
			var settingEmployee = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					otherParam : {
						"organIds" : organIdsEmployee
					},
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClickEmployee,
					onAsyncSuccess : organTreeOnAsyncSuccessEmployee
				}
			};
			var flagEmployee=0;//只初始化一次标识
			function organTreeOnAsyncSuccessEmployee(event, treeId, msg) {
				if(flagEmployee == 0){
					var organTree = $.fn.zTree.getZTreeObj("organSelectTreeEmployee");
					var nodes = organTree.getNodes();
					flagEmployee = 1;
				}
			}
			function onClickEmployee(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("organSelectTreeEmployee");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
					}
				}
				var cityObj = $("#organEmployee");
				cityObj.attr("value", path);
				$("#organIdsEmployee").attr("value", treeNode.id);
				hideMenuEmployee();
			}
			function showMenuEmployee() {
				var cityObj = $("#organEmployee");
				var cityOffset = $("#organEmployee").offset();
				$("#menuContentEmployee").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", onBodyDownEmployee);
			}
			function hideMenuEmployee() {
				$("#menuContentEmployee").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDownEmployee);
			}
			function onBodyDownEmployee(event) {
				if (!(event.target.id == "menuBtn" || event.target.id  == "menuContentEmployee" || $(event.target).parents("#menuContentEmployee").length > 0)){
					hideMenuEmployee();
				}
			}
			$.fn.zTree.init($("#organSelectTreeEmployee"), settingEmployee);
		</script>
	</body>
</html>
